package cn.edu.zxj.ojspring.service;

import cn.edu.zxj.ojspring.mapper.OJMapper;
import cn.edu.zxj.ojspring.model.info.OJInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description：
 *
 * @author: zxj
 * @date: 2024-02-21
 * @time: 17:04:17
 */
@Service
@Slf4j
public class OJService {
    @Autowired
    private OJMapper ojMapper;

    public List<OJInfo> getProblem() {
        try {
            return ojMapper.selectAllOJ();
        } catch (Exception e) {
            log.error("数据库查询题目信息出错, e: {}", e);
        }
        return null;
    }

    public OJInfo getProblemDetail(Integer id) {
        try {
            OJInfo ojInfo = ojMapper.selectOJBy(id);
            ojInfo.setTestCode("");
            return ojInfo;
        } catch (Exception e) {
            log.error("数据库查询题目信息出错, e: {}", e);
        }
        return null;
    }
}
